import express from 'express'
import Mock from 'mockjs'  

const app = express();
const port = 3000;
// 定义一个 Mock 接口
app.get('/api/data', (req, res) => {
    const data = Mock.mock({
        'list|1-10': [
            {
                'id|+1': 1,
                'name': '@cname',
                'age|18-60': 1
            }
        ]
    });
    res.json(data);
});

app.get('/exception', (req, res) => {
    res.status(403).send({ message: 'Internal Server Error'});
});

// 启动服务
app.listen(port, () => {
    console.log(`Mock 服务已启动，访问地址：http://localhost:${port}`);
});